﻿using System;
using System.Collections.Generic;

using System.Text;

namespace YukiFX5017
{
    public class NPCDialogues
    {
        public static Client Cl = new Client(null);
        public static Packets P = General.MyPackets;
         
        public static void Say(string Text)
        {
            Cl.Send(P.NPCSay(Text));
        }
        public static void Link(string Text, byte DialNumber)
        {
            Cl.Send(P.NPCLink(Text, DialNumber));
        }
        public static void Input(string Text, byte DialNumber)
        {
            Cl.Send(P.NPCLink2(Text, DialNumber));
        }
        public static void Finish(int Face)
        {
            Cl.Send(P.NPCSetFace((short)Face));
            Cl.Send(P.NPCFinish());
        }
        public static void NPCTalk(int UID, int Control, Client C)
        {
            Cl = C;
            switch (UID)
            {
                default:
                    {
                        switch (Control)
                        {
                            case 0:
                                {
                                    Say("Hello " + C.MyChar.Name + "! Npc:" + UID + " not Implemented. Please report me on the Forum->BugReports");
                                    Say("Take a Sceenshot (F12) and Upload it to the forum aswell. Doing that will get you more rewards :) ");
                                    Link("Send me to the Forum", 0);
                                    Link("Bye", 255);
                                    Finish(30);
                                    break;
                                }
                            case 1:
                                {
                                    //ChatType:Web->Forum:BugReports
                                    break;
                                }
                        }
                        break;
                    }
                case 0: //IntroductionNPC
                    {
                        switch (Control)
                        {
                            case 0:
                                {
                                    Say("Hello " + C.MyChar.Name + "! Welcome to Spinx, we're currently working on Phase.1");
                                    Say("I hope you can be patient, and wait for phase 1 to finish. Thus you can start your adventure");
                                    Link("I will wait", 255);
                                    Finish(30);
                                    break;
                                }
                        }
                        break;
                    }
                case 1: //CharacterSelection
                    {
                        switch (Control)
                        {
                            case 0:
                                {
                                    Say("Please pick select which character to login with. If it is empty, you will create a new character to it");
                                    Link("[" + C.CharName1 + "]", 1);
                                    Link("[" + C.CharName2 + "]", 2);
                                    Link("[" + C.CharName3 + "]", 3);
                                    Link("[" + C.CharName4 + "]", 4);
                                    Link("[" + C.CharName5 + "]", 5);
                                    Link("Log Off", 6);
                                    Finish(30);
                                    break;
                                }
                            case 1:
                                {
                                    C.MyChar = new Character();
                                    C.CharacterUsage = 1;
                                    C.MyChar.MyClient = C;
                                    C.MyChar.UID = C.UID;
                                    C.Send(General.MyPackets.LanguageResponse(C.MyChar.UID));
                                    C.Send(General.MyPackets.CharacterInfo(C.MyChar));
                                    C.Send(General.MyPackets.AfterChar());
                                    DataBase.GetCharInfo(C.MyChar, C.Account);
                                    C.LoadChar();
                                    break;
                                }
                            case 2:
                                {
                                    if (C.CharName2 == "Empty")
                                    {
                                        Say("The next time you login you will create a new character.");
                                        Link("Log Off", 6);
                                        Finish(30);
                                        Ini CN = new Ini(DataBase.DBPath + @"\Accounts\" + C.Account + ".ini");
                                        CN.Write("Account", "SaveSlot", "2");
                                        CN.Write("Account", "LogonType", "2");
                                        break;
                                    }
                                    else
                                    {
                                        C.MyChar = new Character();
                                        C.CharacterUsage = 2;
                                        C.MyChar.MyClient = C;
                                        C.MyChar.UID = C.UID;
                                        C.Send(General.MyPackets.LanguageResponse(C.MyChar.UID));
                                        C.Send(General.MyPackets.CharacterInfo(C.MyChar));
                                        C.Send(General.MyPackets.AfterChar());
                                        DataBase.GetCharInfo(C.MyChar, C.Account);
                                        C.LoadChar();
                                        break;
                                    }
                                }
                            case 3:
                                {
                                    if (C.CharName3 == "Empty")
                                    {
                                        Say("The next time you login you will create a new character.");
                                        Link("Log Off", 6);
                                        Finish(30);
                                        Ini CN = new Ini(DataBase.DBPath + @"\Accounts\" + C.Account + ".ini");
                                        CN.Write("Account", "SaveSlot", "3");
                                        CN.Write("Account", "LogonType", "2");
                                        break;
                                    }
                                    else
                                    {
                                        C.MyChar = new Character();
                                        C.CharacterUsage = 3;
                                        C.MyChar.MyClient = C;
                                        C.MyChar.UID = C.UID;
                                        C.Send(General.MyPackets.LanguageResponse(C.MyChar.UID));
                                        C.Send(General.MyPackets.CharacterInfo(C.MyChar));
                                        C.Send(General.MyPackets.AfterChar());
                                        DataBase.GetCharInfo(C.MyChar, C.Account);
                                        C.LoadChar();
                                        break;
                                    }
                                }
                            case 4:
                                {
                                    if (C.CharName4 == "Empty")
                                    {
                                        Say("The next time you login you will create a new character.");
                                        Link("Log Off", 6);
                                        Finish(30);
                                        Ini CN = new Ini(DataBase.DBPath + @"\Accounts\" + C.Account + ".ini");
                                        CN.Write("Account", "SaveSlot", "4");
                                        CN.Write("Account", "LogonType", "2");
                                        break;
                                    }
                                    else
                                    {
                                        C.MyChar = new Character();
                                        C.CharacterUsage = 4;
                                        C.MyChar.MyClient = C;
                                        C.MyChar.UID = C.UID;
                                        C.Send(General.MyPackets.LanguageResponse(C.MyChar.UID));
                                        C.Send(General.MyPackets.CharacterInfo(C.MyChar));
                                        C.Send(General.MyPackets.AfterChar());
                                        DataBase.GetCharInfo(C.MyChar, C.Account);
                                        C.LoadChar();
                                        break;
                                    }
                                }
                            case 5:
                                {
                                    if (C.CharName5 == "Empty")
                                    {
                                        Say("The next time you login you will create a new character.");
                                        Link("Log Off", 6);
                                        Finish(30);
                                        Ini CN = new Ini(DataBase.DBPath + @"\Accounts\" + C.Account + ".ini");
                                        CN.Write("Account", "SaveSlot", "5");
                                        CN.Write("Account", "LogonType", "2");
                                        break;
                                    }
                                    else
                                    {
                                        C.MyChar = new Character();
                                        C.CharacterUsage = 5;
                                        C.MyChar.MyClient = C;
                                        C.MyChar.UID = C.UID;
                                        C.Send(General.MyPackets.LanguageResponse(C.MyChar.UID));
                                        C.Send(General.MyPackets.CharacterInfo(C.MyChar));
                                        C.Send(General.MyPackets.AfterChar());
                                        DataBase.GetCharInfo(C.MyChar, C.Account);
                                        C.LoadChar();
                                        break;
                                    }
                                }
                            case 6:
                                {
                                    C.MySocket.Disconnect();
                                    break;
                                }
                        }
                        break;
                    }
            }
        }
    }
}